package servlet;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import bean.Detection;
import bean.Online;
import deo.jiancedeo;
import deo.onlinedeo;

@SuppressWarnings("serial")
public class DetectionServlet extends HttpServlet{
	public void doGet(HttpServletRequest request, HttpServletResponse response)  
            throws ServletException, IOException {  
        this.doPost(request, response);  
    }  
    public void doPost(HttpServletRequest request, HttpServletResponse response)  
            throws ServletException, IOException {
    	
    	jiancedeo db = new jiancedeo();  
        
//    	String sql = " select a.outlet_name,b.draunght_status,b.pur_status,b.oil_con,b.unite,b.humidity,b.temperature,b.pressure,c.company_name,b.mon_date "
//        		+ "from outlet a inner join monitorData b on a.outlet_id=b.outlet_id inner join company c on a.company_id=c.company_id";
//        
    	String sql = " select a.outlet_name,b.draunght_status,b.pur_status,b.oil_con,b.unite,b.humidity,b.temperature,b.pressure,c.company_name,b.mon_date from outlet a inner join monitorData b on a.outlet_id=b.outlet_id inner join company c on a.company_id=c.company_id where mon_date between '2017-05-02' and '2017-05-14' order by c.company_id , mon_date asc ";
        
    	
        ArrayList<Detection> list = null;
		try {
			list = db.getDetectionList(sql);
		} catch (SQLException e) {
			e.printStackTrace();
		}
        request.setAttribute("list", list);  
        request.getRequestDispatcher("jiance.jsp").forward(request, response);  
    }  
}
